define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'bdl/cas/payrecord/index' + location.search,
                    export_url: 'bdl/cas/payrecord/export',
                    table: 'pur_order',
                }
            });

            var table       = $("#table");
            var showExport  = $(".btn-export").data('value')

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                search:false,
                fixedColumns: true,
                fixedRightNumber: 1,
                showToggle: false,
                showExport: showExport,
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: 'ID',operate:false},
                        {
                            field: 'forgid', title: __('数据中心/组织'), searchList: function (column) {
                                return Template('forgidtpl', {});
                            }, formatter: function (value, row, index) {
                                return '无';
                            }, visible: false
                        },
                        {field: 'fenable', title: '使用状态', searchList: {"1":'可用',"0":'禁用'}, formatter: Table.api.formatter.status},

                        {field: 'fk_bdl_erpbillno', title: 'ERP付款单号', operate: 'LIKE'},
                        {field: 'fk_bdl_wxbillno', title: '小程序付款单号', operate: 'LIKE'},
                        {field: 'fk_bdl_paytype', title: '付款类型', searchList: {"1":'微信',"2":'支付宝',"3":'电汇',"4":'银行承兑汇票',"5":'现金'}, formatter: Table.api.formatter.status},

                        {field: 'fk_bdl_paystatus', title: '订单状态', searchList: {"1":'待审核',"2":'未通过',"3":'已确认'}, formatter: Table.api.formatter.status},


                        {field: 'fk_bdl_bd_customer', title: '客户ID', operate: 'LIKE'},
                        {field: 'customer.fname', title: '客户名称', operate: 'LIKE'},

                        {field: 'fk_bdl_paytime', title: '小程序提交时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'fk_bdl_amount', title: '小程序付款金额',operate:'BETWEEN',  autocomplete:false},

                        {field: 'fk_bdl_payvoucher', title: '付款凭证url', operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},

                        {field: 'fk_bdl_erppaytime', title: 'ERP付款时间(包含通过或者不通过)', operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'fk_bdl_erpdesc', title: 'ERP付款说明(包含通过或者不通过)', operate: 'LIKE'},






                        {field: 'datacenter.fname', title: '数据中心名称',operate: false},
                        {field: 'forg.fname', title: '组织名称',operate: false},
                        {field: 'forg.fnumber', title: '组织编码',operate: false},
                        {field: 'forg.id', title: '组织ID',operate: false},


                        {field: 'fk_bdl_creatorid', title: '创建人',operate: false,visible:false,},
                        {field: 'creator.nickname', title: '创建人', operate: 'LIKE',visible:false},
                        {field: 'fk_bdl_createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'fk_bdl_fmodifierid', title: '修改人',operate: false,visible:false,},
                        {field: 'modifier.nickname', title: '修改人', operate: 'LIKE',visible:false},
                        {field: 'fk_bdl_modifytime', title: '修改时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };

    return Controller;
});
